package com.artist.controller;

import com.artist.entity.TbBanner;
import com.artist.service.BannerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@Api(tags = "Banner模块")
@RestController
public class BannerController {
    @Autowired
    private BannerService bannerService;

    @ApiOperation(value = "Banner图列表")
    @GetMapping("/banner")
    public List<TbBanner> getAllBanner(){
        return bannerService.selectAll();
    }

    @ApiOperation(value = "单个Banenr图")
    @GetMapping("/banner/{bId}")
    public  TbBanner getBannerById(@PathVariable Integer bId){
       TbBanner tbBanner= bannerService.selectBannerByPrimaryKey(bId);
        return tbBanner;
    }



    @ApiOperation(value = "新增Banner图")
    @PostMapping("/banner")
    public void insertBanner(@RequestBody TbBanner tbBanner){
        bannerService.savaBanner(tbBanner);
    }


    @ApiOperation(value = "更新Banenr图")
    @PutMapping("/banner/{bId}")
    public  void updateBanner(@RequestBody TbBanner tbBanner){
        bannerService.updateBannerByPrimaryKey(tbBanner);
    }

    @ApiOperation(value = "删除Banner图")
    @DeleteMapping("/banner/{bId}")
    public void deleteBannerByPrimaryKey(@PathVariable Integer bId){
        bannerService.deleteBnanerByPrimaryKey(bId);
    }
}
